package com.clw.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Administrator on 2017-10-18.
 */
public class DateUtils {
    public static Date stringToDate(String data){
        SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd");
        Date date=null;
        try {
            date=s.parse(data);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }

    public static Date addDay(String s,int n){
        try{
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            Calendar cd=Calendar.getInstance();
            cd.setTime(sdf.parse(s));
            cd.add(Calendar.DATE,n);
            return sdf.parse(sdf.format(cd.getTime()));
        }catch (Exception e){
            return null;
        }
    }
}
